<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 2. 定义根标签 -->
    <div id="root"></div>
    <!-- 1. 引入react的文件-->
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.js"></script>
    <!-- type="text/babel"的作用:让babel编译当前script标签中的代码 -->
    <script type="text/babel">
      // 3.根据需求创建虚拟dom
      // 需求: 当age大于或等于18时,渲染`hj是lsp`.否则渲染`hj不是lsp`
      let age = 16
      // const div = <div>{age >= 18 ? <h1>hj是lsp</h1> : <h1>hj不是lsp</h1>}</div>
      let flag = false
      // const div = <div>{flag ? <h1>hj是No.1</h1> : undefined}</div>
      const div = <div>{flag && <h1>hj是No.1</h1>}</div>

      // 4. 根据虚拟dom创建真实dom并渲染
      ReactDOM.createRoot(document.getElementById('root')).render(div)
    </script>
  </body>
</html>
